package com.banksoft.cps.controller.admin;

import com.banksoft.cps.bean.MonitorProduct;
import com.banksoft.cps.controller.ControllerConstants;
import com.banksoft.cps.service.MonitorValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by rongzhao.zhu on 2018/5/30.
 */
@Controller
@RequestMapping("/admin/monitorDataImport/")
public class AdminMonitorImportController  extends ControllerConstants {

    @Autowired
    MonitorValueService monitorValueService;
    @RequestMapping(value = "import", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String importData(String deviceId, String path , HttpServletRequest request){
        try {
            monitorValueService.importMonitorValue(deviceId,getWebPath(request)+path);

             return toJSONString(SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            return toExceptionString(e);
        }
    }
}
